window.onload = function () {
    // 页面等待加载
    let lis = document.querySelectorAll(".catalogue>ul>li")
    let firsts = document.querySelectorAll(".firsts")
    let lasts = document.querySelectorAll(".lasts")
    // 循环li标签
    for (let a = 0; a < lis.length; a++) {
        // 移入事件添加active和show
        lis[a].onmouseover = function () {
            this.querySelector(".firsts").className = "firsts active"
            this.querySelector(".lasts").className = "lasts show"
        }
        // 移除事件active和show
        lis[a].onmouseout = function () {
            this.querySelector(".firsts").className = "firsts"
            this.querySelector(".lasts").className = "lasts"
        }
    }
    // 获取标签
    let singles = document.querySelector(".single")
    let banners = document.querySelectorAll(".banner")
    let num = 0
    // 设置时间间隔
    setInterval(function () {
        num++
        startMove(singles, { "left": num * (-1000) }, 1000, "linear", function () {
            if (num == banners.length - 1) {
                num = 0
                singles.style.left = 0
            }
        })
    }, 3000)
    // 拿去标签
    let Jumps = document.querySelectorAll(".Jump")
    let itemBoxs = document.querySelectorAll(".itemBox")
    for (let i = 0; i < Jumps.length; i++) {
        // 当前移入显示事件
        Jumps[i].addEventListener("mouseover", function () {
            for (let j = 0; j < Jumps.length; j++) {
                Jumps[j].className = "Jump fl"
                itemBoxs[j].className = "itemBox"
            }
            // 当前做移出事件
            Jumps[i].className = "Jump fl active1"
            itemBoxs[i].className = "itemBox show"
        })
    }
    // 手风琴标签
    let lsts = document.querySelectorAll(".right-e-books li")
    let bookname = document.querySelectorAll(".e-book-name")
    let info = document.querySelectorAll(".book-info")
    for (let a = 0; a < lsts.length; a++) {
        lsts[a].addEventListener("mouseover", function () {
            for (let b = 0; b < lsts.length; b++) {
                bookname[b].className = "e-book-name fl show"
                info[b].className = "book-info fl clearfix  none"
            }
            bookname[a].className = "e-book-name fl none"
            info[a].className = "book-info fl clearfix show"
        })
    }
    // 拿去服装标签
    let clothingBox = document.querySelectorAll(".clothing-text1")
    let twoBoxs = document.querySelectorAll(".clothing-box-two")
    for (let c = 0; c < clothingBox.length; c++) {
        // 当前移入显示事件
        clothingBox[c].addEventListener("mouseover", function () {
            for (let d = 0; d < clothingBox.length; d++) {
                clothingBox[d].className = "clothing-text1 fl"
                twoBoxs[d].className = "clothing-box-two"
            }
            // 当前做移出事件
            clothingBox[c].className = "clothing-text1 fl active1"
            twoBoxs[c].className = "clothing-box-two show"
        })
    }
    // 拿去童装标签
    let wears = document.querySelectorAll(".wear-books")
    let zongs = document.querySelectorAll(".zong")
    for (let e = 0; e < wears.length; e++) {
        // 当前移入显示事件
        wears[e].addEventListener("mouseover", function () {
            for (let f = 0; f < wears.length; f++) {
                wears[f].className = "wear-books fl"
                zongs[f].className = "zong"
            }
            // 当前做移出事件
            wears[e].className = "wear-books fl active2"
            zongs[e].className = "zong show"
        })
    }
    // 拿去推广商品标签
    let titles = document.querySelectorAll(".box-title")
    let tissues = document.querySelectorAll(".tissue-box")
    for (let t = 0; t < titles.length; t++) {
        titles[t].addEventListener('mouseover', function () {
            for (let h = 0; h < titles.length; h++) {
                titles[h].className = "box-title fl"
                tissues[h].className = "tissue-box"
            }
            titles[t].className = "box-title fl fl active3"
            tissues[t].className = "tissue-box show"
        })
    }
    // 顶部隐藏搜索框
    let searchs = document.querySelector("#search-inp");
    window.addEventListener("scroll", function () {
        let top = document.body.scrollTop || document.documentElement.scrollTop;
        if (top >= 600) {
            searchs.style.height = "50px";
            searchs.style.borderBottom = "1px solid #f60";
        } else {
            searchs.style.height = "";
            searchs.style.borderBottom = "none";
        }
    })
    // 搜索框的值显示
    let olds = document.querySelector("#oldBox")
    let news = document.querySelector("#newBox")
    olds.addEventListener("input", function () {
        news.value = this.value
    })
    news.addEventListener("input", function () {
        olds.value = this.value
    })

    // 跳转楼层
    let floors = document.querySelectorAll(".floor li");
    let icoms = document.querySelectorAll(".floor-icom");
    let boxs = document.querySelectorAll(".floor-box");
    for (let g = 0; g < floors.length; g++) {
        floors[g].addEventListener("mouseover", function () {
            let u = g * (-40)
            icoms[g].style.background =`url("../imgs/floor.png") -40px ${u}px #93d46f`
            boxs[g].style.display = "block" 
        })
        floors[g].addEventListener("mouseout", function () {
            let u = g * (-40)
            icoms[g].style.background =`url("../imgs/floor.png") 0 ${u}px #f2f2f2`
            boxs[g].style.display = "none" 
        })
    }
// 放回顶部按钮
let tops = document.querySelector(".top-box")
tops.addEventListener("click",function(){
   let time= setInterval(function(){
     let k = document.body.scrollTop || document.documentElement.scrollTop
        if(k<=0){
clearInterval(time)
        }
        k-=50
        document.body.scrollTop = k
        document.documentElement.scrollTop= k
    },30)
})
 








}